<?php

namespace App\Admin\Controllers;

use App\Admin\Services\OperationLogService;

class OperationLogController extends Controller
{
    protected $operationLogService;

    public function __construct(OperationLogService $operationLogService)
    {
        parent::__construct();
        $this->operationLogService = $operationLogService;
    }

    /**
     * 登錄日誌列表
     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        $input = request()->only(['ip', 'time', 'limit', 'staff_id']);

        if (request()->expectsJson()) {
            $users = $this->operationLogService->getLogList($input);
            $items    = $users->items();
            return $this->laytable($users->total(), (array)$items);
        }

        return view('admin.operation.log', ['input' => $input]);
    }

}
